﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.MaterialExport"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:Groupbox="clr-namespace:Groupbox;assembly=Groupbox"
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.MaterialExportViewModel">

    <telerik:RadBusyIndicator 
        BusyContent="Đang kết nối tới máy chủ..." 
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}">
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="3" >

                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle" 
                        Style="{StaticResource TextBlockTitlePageStyle}"                          
                        Text="Xuất lô Nguyên liệu"/>
            </Grid>

            <!--group box exporting material information-->
            <Groupbox:GroupBox Grid.Column="1" Grid.Row="2">
                <Groupbox:GroupBox.Header>
                    <TextBlock Text="Thông tin nguyên liêu"
                               Style="{StaticResource TextBlockGroupBoxTitleStyle}">
                    </TextBlock>
                </Groupbox:GroupBox.Header>
                <!--Text box area-->
                <Grid x:Name="TextBoxField" Grid.Column="1" Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40"/>
                        <RowDefinition Height="40"/>
                        <RowDefinition Height="40"/>
                        <RowDefinition Height="40"/>
                        <RowDefinition Height="40"/>
                        <RowDefinition Height="40"/>
                    </Grid.RowDefinitions>
                    <!--Material name-->
                    <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="0">
                        <Run Text="Tên vật liệu " />
                        <Run Text="*" Foreground="Red"/>
                    </TextBlock>
                    <ComboBox 
                        x:Name="cbMaterialName"                         
                        Style="{StaticResource ComboBoxNormalStyle}"
                        Grid.Column="1" Grid.Row="0"
                        ItemsSource="{Binding Path=MaterialCollection, Mode=TwoWay}"                    
                        SelectedItem="{Binding Path=CurrentMaterial,Mode=TwoWay}" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                    <TextBlock
                                        Text="{Binding Path=MaterialCode}" 
                                        />
                                    <TextBlock
                                        Text="-" 
                                        />
                                    <TextBlock
                                        Text="{Binding Path=MaterialName}"
                                        />
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>

                    </ComboBox>
                    <!--PricePerUnit-->
                    <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="2">
                        <Run Text="Đơn giá (VND) " />                        
                    </TextBlock>
                    <TControls:RadNumericUpDown
                            x:Name="txtPricePerUnit"
                            Grid.Column="1" Grid.Row="2"
                            Margin="5,2" IsInteger="False"
                            Minimum="0"  Height="25"
                            Value="{Binding Path=PricePerUnit, Mode=TwoWay}">
                    </TControls:RadNumericUpDown>
                    <!--<Grid Grid.Row="2" Grid.Column="1">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="90"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TControls:RadNumericUpDown
                            x:Name="txtPricePerUnit"
                            Grid.Column="1" Grid.Row="0"
                            Width="180" HorizontalAlignment="Right"
                            Margin="5,2" IsInteger="False"
                            Minimum="0" 
                            Value="{Binding Path=PricePerUnit, Mode=TwoWay}">
                        </TControls:RadNumericUpDown>
                        <TextBlock Grid.Row="0" Grid.Column="2"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Center"
                               TextAlignment="Right"
                               Text=" VND"/>
                    </Grid>-->
                    <!--Quantity-->
                    <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="1">
                        <Run Text="Số lượng " />
                        <Run Text="*" Foreground="Red"/>
                    </TextBlock>
                    <TControls:RadNumericUpDown
                        Grid.Column="2" Grid.Row="1"
                        Margin="5,2" IsInteger="True"
                        Minimum="0" Height="25"
                        Value="{Binding Path=TotalQuantity, Mode=TwoWay}">
                    </TControls:RadNumericUpDown>
                    <!--Quantity in store-->
                    <TextBlock
                        Style="{StaticResource TextBlockNormalStyle}"
                        Grid.Column="0" Grid.Row="3">
                        <Run Text="Số lượng trong kho :" />
                    </TextBlock>
                    <TextBlock x:Name="lblQuantityInStore"  
                        TextAlignment="Center"
                        HorizontalAlignment="Left"
                        Style="{StaticResource TextBlockNormalStyle}" 
                        Grid.Column="2" Grid.Row="3" 
                        Text="{Binding Path=CurrentMaterial.Quantity}" VerticalAlignment="Center">
                        
                    </TextBlock>

                    <!--Error label-->
                    <TextBlock x:Name="lblError" Style="{StaticResource ErrorMessageTextBlockStyle}" 
                        Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4"
                        HorizontalAlignment="Right"
                        TextAlignment="Right"
                       Text="{Binding Path=ErrorMessage}" Visibility="Visible">                        
                    </TextBlock>

                    <StackPanel
                        Orientation="Horizontal" HorizontalAlignment="Center"
                        Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="2">
                            <!--Buttons-->
                            <Controls:SaveButtonControl 
                        Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />

                            <Controls:ResetButtonControl 
                        Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                        />

                            <Controls:BackButtonControl
                        />
                    </StackPanel>
                </Grid>
                
            </Groupbox:GroupBox>
          
           
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
